package view.entities;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

import view.test.EntityMouseInputListener;
import view.test.GlassPane;
import controller.GameController;

public class ViewEntity extends JLabel {
	
	private static final long serialVersionUID = 6862719047626794975L;
	private IViewFactory viewFactory;
	private ImageIcon entityIcon;
	
	public ViewEntity(Point cell, GameController controller, GlassPane pane) {
		this.setBackground(new Color(0,0,0));
		this.setForeground(Color.WHITE);
		this.setHorizontalAlignment(JLabel.CENTER);
		EntityMouseInputListener listener = new EntityMouseInputListener(cell, controller, pane);
		this.addMouseListener(listener);
		this.addMouseMotionListener(listener);
	}
	@Override
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		Graphics2D g2 = (Graphics2D) g;
		if (viewFactory != null)
		viewFactory.paintEntity(g2);
	}

	public void setViewFactory(IViewFactory viewFactory) {
		this.viewFactory = viewFactory;
	}
	public ImageIcon getEntityIcon() {
		return entityIcon;
	}
	public void setEntityIcon(ImageIcon entityIcon) {
		this.setIcon(entityIcon);
		this.entityIcon = entityIcon;
	}

}
